package cn.com.bluemoon.daps.sync.service.impl;

import cn.com.bluemoon.daps.common.exception.DapException;
import cn.com.bluemoon.daps.sync.entity.DapSyncProdEnvTask;
import cn.com.bluemoon.daps.sync.mapper.DapSyncProdEnvTaskMapper;
import cn.com.bluemoon.daps.sync.service.DapSyncProdEnvTaskService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 发布同步单号数据维护 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-06-17
 */
@Slf4j
@Service
public class DapSyncProdEnvTaskServiceImpl extends ServiceImpl<DapSyncProdEnvTaskMapper, DapSyncProdEnvTask>
        implements DapSyncProdEnvTaskService {

    @Transactional(rollbackFor = DapException.class)
    @Override
    public void updateSyncFailOnSandbox(String taskId, boolean sandboxSyncFail) {
        LambdaUpdateWrapper<DapSyncProdEnvTask> setSandboxSyncFailW = bmLambdaUpdate().eq(DapSyncProdEnvTask::getId, taskId).set(DapSyncProdEnvTask::getSandboxSyncFail, sandboxSyncFail);
        boolean update = update(setSandboxSyncFailW);
        log.info("更改任务id={}，状态为：{}，情况：{}", taskId, sandboxSyncFail, update);
    }
}
